<?php
$xtpl = new XTemplate("modules/home/service_task.htm");
//--
$UPLOAD = new UPLOAD();
//--
$POST = $_POST;

if($_POST[type] == 'NEW'){	
    $POST['sp_image'] = $UPLOAD->doUploadImage("upload/service/", 'image', '', '150', '');	
	$POST['sp_name']=$POST['name'];
	$POST['sp_text']= $POST['description'];
	$POST['sp_meta_description']	= $POST['meta_description'];
	$POST['sp_meta_keyword']	= $POST['meta_keyword'];
	$POST['sp_short_description']	= $POST['short_description'];
    $POST['id_lang'] = $_SESSION['ID_LANG_ADM'];
	//--
	$DB->DBInsert('service', $POST);
	//--
	$GUI->redir("?mod=home&act=service");
}
elseif($_POST[type] == 'EDIT'){
    if($_FILES['image']['name'] !=''){
	 	$POST['sp_image'] = $UPLOAD->doUploadImage("upload/service/", 'image', '', '150', '');
	}
	$POST['sp_meta_description']	= $POST['meta_description'];
	$POST['sp_meta_keyword']	= $POST['meta_keyword'];

	$POST['sp_name']	= $POST['name'];
	$POST['sp_short_description']	= $POST['short_description'];
	$POST['sp_text']= $POST['description'];

	//--
	$DB->DBUpdate('service', $POST, "WHERE sp_id = '".$POST['id']."'");
	//--
	$GUI->redir("?mod=home&act=service");
}
//--
//--
if($_GET[id] != ''){
	$row = $DB->FetchData('service','*',"WHERE sp_id='".$_GET[id]."'");
	$row['type'] = 'EDIT';
	$row['code']=stripslashes($row['sp_code']);
	$row['meta_keyword']=stripslashes($row['sp_meta_keyword']);
	$row['meta_description']=stripslashes($row['sp_meta_description']);
	$row['short_description']	= stripslashes($row['sp_short_description']);
	$row['id']=$row['sp_id'];
	$row['name'] = $row['sp_name'];
    if($row['sp_image']!=''){	
		$row['show_image']='<img src="../upload/service/thumb'.$row['sp_image'].'" border="0" width="65">';
	}
	
}else{
	$row[type] = 'NEW';
}
//--
//--
$_FCKeditor = new FCKeditor("description");
$_FCKeditor->BasePath = $siteFCKeditorPath;
$_FCKeditor->Width = '95%';
$_FCKeditor->Height = '450';
$_FCKeditor->Value = stripslashes($row['sp_text']);

$xtpl->assign("write",$row);
//--
//--
$waypathlink = '&raquo;&nbsp;<a href="?mod=home&act=supplier" class="waypath">Service Management</a>:&nbsp;'.$row[type];
$xtpl_main->assign("waypathlink",$waypathlink);
//--
//--
$save_button = $GUI->button_ren("Save","javascript: doSavenews();");
$xtpl->assign("save_button",$save_button);
//--
$cancel_button = $GUI->button_ren("Cancel","javascript: add('?mod=home&act=service');");
$xtpl->assign("cancel_button",$cancel_button);

?>
